<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>


<body>
  <div id="test"></div>
  <div id="test2"></div>

</body>



<script type="text/javascript" src="../js/react.development.js"></script>
<script type="text/javascript" src="../js/react-dom.development.js"></script>
<script type="text/javascript" src="../js/babel.min.js"></script>
<script type="text/javascript" src="../js/prop-types.js"></script>

<script type="text/babel"> //必须声明 babel
  class Person extends React.Component {
    static propTypes = {
        name: PropTypes.string.isRequired,
        age: PropTypes.number.isRequired,
        sex: PropTypes.string,
        spack: PropTypes.func
    }
    static defaultProps = {
        sex: '不男不女',
        age: 18 
    }
    render () {
      const { name, sex, age } = this.props
      return (
        <ul>
          <li>姓名:{name}</li>
          <li>年龄:{age + 1}</li>
          <li>性别:{sex}</li>
        </ul>
      )
    }
  }
  // Person.propTypes = {
  //   name: PropTypes.string.isRequired,
  //   sex: PropTypes.string,
  //   age: PropTypes.number,
  //   spack: PropTypes.func
  // }
  // Person.defaultProps = {
  //   sex: '不男不女',
  // }
  const p = {
    name: '李四',
    age: 19,
    sex: '男',

  }
  // ReactDOM.render(<Person name='张三' age='18' sex='男' />, document.getElementById('test'))
  ReactDOM.render(<Person name='张三' />, document.getElementById('test'))

  ReactDOM.render(<Person {...p} spack={spack} />, document.getElementById('test2'))


  function spack () {
    console.log('说话了');
  }
</script>

</html>